home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
OldSrc
/
CH2
/
SRC
/
SCALE.FRM
< prev
next >
Wrap
Text File
|
1995-12-21
|
2KB
|
74 lines
VERSION 4.00
Begin VB.Form ScaleForm
AutoRedraw = -1 'True
Caption = "Scaling custom coordinates to pixels"
ClientHeight = 4140
ClientLeft = 2235
ClientTop = 1590
ClientWidth = 4140
Height = 4830
Left = 2175
LinkTopic = "Form1"
ScaleHeight = -12
ScaleLeft = -1
ScaleMode = 0 'User
ScaleTop = 11
ScaleWidth = 12
Top = 960
Width = 4260
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "ScaleForm"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Dim X1 As Integer
Dim Y1 As Integer
Dim X2 As Integer
Dim Y2 As Integer
Dim scale_left As Single
Dim scale_top As Single
Dim pix_per_unit_x As Single
Dim pix_per_unit_y As Single
' Custom coordinates for the points.
X1 = 0
Y1 = 2
X2 = 10
Y2 = 8
' Draw an X.
Line (X1, Y1)-(X2, Y2)
Line (X1, Y2)-(X2, Y1)
' Prepare for translation.
scale_left = ScaleX(ScaleLeft, ScaleMode, 3)
scale_top = ScaleY(ScaleTop, ScaleMode, 3)
pix_per_unit_x = ScaleX(1, ScaleMode, 3)
pix_per_unit_y = ScaleY(1, ScaleMode, 3)
' Translate coordinates into pixels.
X1 = X1 * pix_per_unit_x - scale_left
Y1 = Y1 * pix_per_unit_y - scale_top
X2 = X2 * pix_per_unit_x - scale_left
Y2 = Y2 * pix_per_unit_y - scale_top
' Draw a box around the X.
If Rectangle(hDC, X1, Y1, X2, Y2) = 0 Then Exit Sub
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub